package Flyweight;

import java.util.HashMap;
import java.util.Map;

public class FlyweightFactory {
	
	private Map<Character, Flyweight> map = new HashMap<Character, Flyweight>();
	
	//单例模式的基本模式
	public Flyweight factory(Character state) {
		
		Flyweight fly = map.get(state);
		if (fly == null) {
			fly = new ConcreteFlyweight(state);
			map.put(state, fly);
		}
		return fly;
	}
}
